Skip to content

fix(describe): emit workflow annotations as comments, not statements (mendixlabs/mxcli#1007) - #351

Merged
ako merged 3 commits into
mainfrom
fix/workflow-describe-annotation-comments
Aug 31, 2026
Merged

fix(describe): emit workflow annotations as comments, not statements (mendixlabs/mxcli#1007)#351
ako merged 3 commits into
mainfrom
fix/workflow-describe-annotation-comments

Conversation

@ako

@ako ako commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Fixes mendixlabs/mxcli#1007. Stacked on #348 (same function, formatAnnotation) — base is fix/workflow-describe-quote-doubling; retarget to main once that merges.

DESCRIBE WORKFLOW emitted annotation '<text>'; — the exact construct MDL-WF04 exists to refuse, and that execCreateWorkflow refuses again. So the describer produced output mxcli's own checker rejects: 13 MDL-WF04 errors from one unmodified describe of a 23-activity workflow.

Two parts of the tree disagreed, in comments

the emitter: "The annotation is emitted as a parseable MDL statement so it survives round-trips."

the validator: it "produces a model Mendix cannot load (the annotation is placed in the activity flow, which accepts only flow elements) — Studio Pro will not open the project"

The emitter's comment was the stale one.

One correction to the issue's framing, and it changes the fix

The report reads these as canvas annotations. They aren't: formatAnnotation is called at 10 sites, always with an activity's attached Annotation, and the describer converted attached → standalone, which is the refused form.

That matters, because the issue's option 2 ("support writing annotations, relax MDL-WF04") needs a grammar change: MDLWorkflow.g4 has only the standalone workflowAnnotationStmt, so no MDL input can express an attached annotation today — even though the write path stores one (addActivityBaseFields). Commenting it out therefore loses nothing that was reachable, which is what makes option 1 honest rather than a concession.

Worth knowing: the microflow domain already solved this

MDLMicroflow.g4 has @annotation 'text' as an activity prefix and round-trips it properly. Giving workflow activities the same prefix is the non-lossy fix — the annotation would survive a rebuild instead of being commented out. That's a grammar change across every workflow activity rule, so it's a feature, deliberately not bundled here. Happy to open it as a follow-up.

Two traps in the implementation

  • A -- comment runs to end of line, so a multi-line annotation must be prefixed per line, or the tail becomes stray tokens — the same failure the statement form had.
  • The standalone branch must set isComment, or the terminator logic appends ; to a comment line.

Tests

Four, verified against the old emitter:

--- FAIL: TestDescribeWorkflow_AttachedAnnotationPassesOwnCheck
    describe output still trips MDL-WF04
--- FAIL: TestDescribeWorkflow_StandaloneAnnotationPassesOwnCheck
    describe output still trips MDL-WF04
--- FAIL: TestDescribeWorkflow_MultiLineAnnotationCommentsEveryLine

Each asserts the emitted MDL parses, passes ValidateWorkflow, and still contains the text — the last because dropping the annotation entirely would satisfy the first two. The fourth test (NoAnnotationEmitsNoComment) passes both before and after, on purpose: it's the control that the change adds no stray comment lines.

🤖 Generated with Claude Code

ako and others added 2 commits August 31, 2026 18:53
DESCRIBE WORKFLOW emitted `annotation '<text>';` — the exact construct
MDL-WF04 exists to refuse, and that execCreateWorkflow refuses again. So
the describer produced output mxcli's own checker rejects: 13 MDL-WF04
errors from one unmodified describe of a 23-activity workflow.

Two parts of the tree disagreed, each stating its position in a comment.
The emitter: "emitted as a parseable MDL statement so it survives
round-trips." The validator: it "produces a model Mendix cannot load
(the annotation is placed in the activity flow, which accepts only flow
elements)". The emitter's comment was the stale one.

The reporter read these as canvas annotations. They are not:
formatAnnotation is called at 10 sites, always with an activity's
ATTACHED Annotation, and the describer converted attached to standalone
— which is the refused form. That matters for the fix, because
MDLWorkflow.g4 has only the standalone workflowAnnotationStmt: no MDL
input can express an attached annotation, even though the write path
stores one. Commenting it out therefore loses nothing that was
reachable.

Both emit paths become comments — the attached one and the standalone
WorkflowAnnotationActivity read back from a model. The standalone branch
also has to mark itself a comment, or the terminator logic appends `;`.

The microflow domain already has an attached form (`@annotation 'text'`)
that round-trips properly. Giving workflow activities the same prefix
would preserve the annotation instead of commenting it out; that is a
grammar change and deliberately not bundled here.

Tests assert the emitted MDL parses, passes ValidateWorkflow, AND still
contains the text — the last one because dropping the annotation
entirely would satisfy the first two.

Reported as mendixlabs#1007.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ako
ako changed the base branch from fix/workflow-describe-quote-doubling to main August 31, 2026 20:35
@ako
ako merged commit 86640af into main Aug 31, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant